﻿// DbProviderLib
// (c)2007 Mark Bulmahn. mBulmahn@web.de
// License: GPL 2.0
// Project: TestCaseGenerator. http://www.codeplex.com/TestCaseGenerator

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DbProviderLib
{
    /// <summary>
    /// A factory to get the desired provider according to the DbType
    /// </summary>
    public class DbProviderFactory
    {
        public enum DbType { MSSQL = 1, SQLCE = 2, ORACLE = 3 }

        public static IDbProvider GetProvider(DbProviderFactory.DbType t, string connStr)
        {
            IDbProvider result = null;
            switch (t)
            {
                case DbProviderFactory.DbType.MSSQL:
                    result = new MssqlProvider(connStr);
                    break;
                case DbProviderFactory.DbType.SQLCE:
                    result = new SqlCeProvider(connStr);
                    break;
                case DbProviderFactory.DbType.ORACLE:
                    throw new Exception("Not yet implemented.");
                default:
                    throw new Exception("Not implemented.");
            }
            return result;
        }
    }
}
